import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';

import '../controller/CountController.dart';

class ListPage extends StatefulWidget {
  const ListPage({super.key});

  @override
  State<ListPage> createState() => _ListPageState();
}

class _ListPageState extends State<ListPage> {
  // 查找需要的共享实例
  final CountController _countController = Get.find<CountController>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("列表页"),

        
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text("列表页"),
            const SizedBox(height: 20),
            Obx(() => Text("计数：${_countController.count}")),
            ElevatedButton(
                onPressed: () {
                  _countController.increase();
                },
                child: const Text("修改值")),

            const SizedBox(height: 20),
            // 3. 接收参数
            Text(Get.arguments?["name"] ?? "无参数"),
            const SizedBox(height: 20),
            ElevatedButton(
                onPressed: () {
                  // 1. 页面跳转
                  Get.back();
                },
                child: const Text("返回"))
          ],
        ),
      ),
    );
  }
}
